home *** CD-ROM | disk | FTP | other *** search
/ Directorty Opus 5 - Magellan 2 / Opus 5 - Magellan 2.iso / Extras / D51_NUSource / Source / Routines / OpenLibraries_Error_Shell.s < prev    next >
Text File  |  1995-08-02  |  3KB  |  101 lines

  1. ;---------------------------------------------------------------------------;
  2. ; Obviously, the error routine should not rely upon any libs being open!!   ;
  3. ; Temp001(a5) will be used as a base for dos.library                        ;
  4. ; Temp002(a5) will be used as the adr of the allocated mem for error text.  ;
  5. ; - This routine will attempt to open dos, get the output handle and list   ;
  6. ;   which libraries couldn't be openned (including the required versions).  ;
  7. ;---------------------------------------------------------------------------;
  8. OpnLib_Error_Title
  9.     PROGNAM
  10.     Dc.b    ": Could not open the following libraries:",10
  11.     Dc.b    "(Minimum version numbers shown.)",10,10
  12. OpnLib_Error_L    Equ *-OpnLib_Error_Title
  13.  
  14. OpnLib_Error_Body_Main_Length Equ 40
  15. ; 30 chars = maximum filename length, + " vXX",10,0 + a bit more.
  16.  
  17.     Even
  18. ;---------------------------------------------------------------------------;
  19. OpnLib_Error
  20.     Lea    N_DOSName(pc),a1
  21.     Moveq    #0,d0            ANY version of dos.library
  22.     N_CallExec    OpenLibrary
  23.     Move.l    d0,Temp001(a5)        Store base adr.
  24.     Beq    Finish            If we can't get it, Exit!
  25.  
  26.     Move.l    Temp001(a5),a6
  27.     Jsr    _LVOOutput(a6)        -._ Get output Handle
  28.     Move.l    d0,CLI_Hdl(a5)        -'  (CLI window or whatever)
  29.  
  30.     Lea    OpnLib_Error_Title(pc),a0
  31.     Moveq    #OpnLib_Error_L,d3
  32.     Bsr.s    OLE_CLIRite
  33.  
  34.     Bsr.s    BuildLibList
  35.  
  36. OpnLib_Error__2
  37.     Move.l    Temp001(a5),a1        -.
  38.     N_CallExec    CloseLibrary     |- Close dos.library
  39.     Bra    Finish            -'  and Finish program.
  40. ;---------------------------------------------------------------------------;
  41. BuildLibList
  42.     Moveq    #OpnLib_Error_Body_Main_Length,d0
  43.     Bsr    LeoAllocPooled        Alloc mem for message.
  44.     Move.l    d0,Temp002(a5)
  45.     Beq.s    OpnLib_Error__2        If Allocation failed, Exit Program
  46.  
  47.     Lea    LibData_Start(pc),a2    Start of struc w/ name-ptrs and ver#s
  48.     Lea    LibBases_Start(a5),a3    Start of struc w/ Base-Adrs.
  49.  
  50. BuildLibList_MainLoop
  51.     Lea    LibBases_Finish(a5),a4
  52.     Cmp.l    a4,a3            All libraries been checked?
  53.     Blt.s    OLEBL_Skp1
  54.  
  55.     Moveq    #OpnLib_Error_Body_Main_Length,d0    -.
  56.     Move.l    Temp002(a5),a1                 |- Deallocate Msg mem.
  57.     Bsr    LeoFreePooled                -'
  58.     RTS                If so, exit.
  59.  
  60. OLEBL_Skp1
  61.     Tst.l    (a3)+            Did this lib fail to open?
  62.     Beq.s    OLEBL_Skp2        If not, don't include in msg.
  63.     Addq.l    #8,a2            Update the other pointer.
  64.     Bra.s    BuildLibList_MainLoop    Check the rest of the libs.
  65.  
  66. OLEBL_Skp2
  67.     Lea    LibNames_Start(pc),a0    -._ Point to the name of
  68.     Add.l    (a2)+,a0        -'  the lib.
  69.     Move.l    Temp002(a5),a1        Space to put it in.
  70.     Bsr    CopyCN3            Copy it (excluding null).
  71.     Move.b    #" ",(a1)+        A space after it.
  72.     Move.b    #"v",(a1)+        version...
  73.  
  74.     Move.l    (a2)+,d1        Version of lib.
  75.     Bsr    N2A2Dig            Convert number to output.
  76. ;    Note: N2A2Dig ONLY uses d1 and a1.
  77.     Move.b    #10,(a1)+        A return after it.
  78.  
  79.     Movem.l    a2/a3,-(SP)
  80.     Move.l    Temp002(a5),a0        Adr of line.
  81.     Move.l    a1,d3            -._ Length of
  82.     Sub.l    a0,d3            -'  line.
  83.     Bsr.s    OLE_CLIRite        Write to shell.
  84.     Movem.l    (SP)+,a2/a3
  85.  
  86.     Bra.s    BuildLibList_MainLoop
  87. ;---------------------------------------------------------------------------;
  88. ;- CLI WRITE (For OpenLibrary Error routine) -------------------------------;
  89. ;---------------------------------------------------------------------------;
  90. ; a0 = Start of text to be written    | d3 = #Chars to be Written           ;
  91. ; CLI_Hdl(a5) - Handle of CLI         |                                     ;
  92. ;---------------------------------------------------------------------------;
  93. OLE_CLIRite
  94.     Move.l    a0,d2
  95.     Move.l    CLI_Hdl(a5),d1
  96.     Move.l    Temp001(a5),a6
  97.     Jsr    _LVOWrite(a6)
  98.     Cmpi.l    #-1,d0
  99.     Beq    Finish            Quit program NOW if there's an error.
  100.     RTS
  101.